home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2006 May / PCWMAY06.iso / Software / Freeware / First Page 2006 3.00 / fp2006-final-3.00-setup.exe / {app} / Iscripts / Forms Misc / auto-tab.izs < prev    next >
Text File  |  2005-09-28  |  4KB  |  165 lines

  1. <!NOWIZARD>
  2.  
  3. <!TITLE>Auto Tab 
  4. <!/TITLE>
  5.  
  6. <!DESCRIPTION>This script automatically moves you to the next box once youve entered enough digits into the box before it!<!/DESCRIPTION> 
  7.  
  8. <!CATEGORY>Forms<!/CATEGORY>
  9.  
  10. <!SCRIPT>
  11. <!-- START OF SCRIPT -->
  12.  
  13. <!-- HOW TO INSTALL AUTO TAB:
  14.  
  15.   1.  Copy code into the HEAD section of document
  16.   2.  Put last coding into the BODY section of document  -->
  17.  
  18. <!-- STEP ONE: Add code into HEAD section of document  -->
  19.  
  20. <HEAD>
  21.  
  22. <SCRIPT LANGUAGE="JavaScript">
  23. <!-- Original:  Cyanide_7 (leo7278@hotmail.com) -->
  24. <!-- Web Site:  http://members.xoom.com/cyanide_7 -->
  25.  
  26.  
  27. <!-- Begin
  28. var isNN = (navigator.appName.indexOf("Netscape")!=-1);
  29. function autoTab(input,len, e) {
  30. var keyCode = (isNN) ? e.which : e.keyCode; 
  31. var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46];
  32. if(input.value.length >= len && !containsElement(filter,keyCode)) {
  33. input.value = input.value.slice(0, len);
  34. input.form[(getIndex(input)+1) % input.form.length].focus();
  35. }
  36. function containsElement(arr, ele) {
  37. var found = false, index = 0;
  38. while(!found && index < arr.length)
  39. if(arr[index] == ele)
  40. found = true;
  41. else
  42. index++;
  43. return found;
  44. }
  45. function getIndex(input) {
  46. var index = -1, i = 0, found = false;
  47. while (i < input.form.length && index == -1)
  48. if (input.form[i] == input)index = i;
  49. else i++;
  50. return index;
  51. }
  52. return true;
  53. }
  54. //  End -->
  55. </script>
  56. </HEAD>
  57.  
  58. <!-- STEP TWO: Add code into BODY section of document  -->
  59.  
  60. <BODY>
  61.  
  62. <center>
  63. <form>
  64. <table>
  65. <tr>
  66. <td>Phone Number : <br>
  67. 1 - (
  68. <small><input onKeyUp="return autoTab(this, 3, event);" size="4" maxlength="3"></small>) - 
  69. <small><input onKeyUp="return autoTab(this, 3, event);" size="4" maxlength="3"></small> - 
  70. <small><input onKeyUp="return autoTab(this, 4, event);" size="5" maxlength="4"></small>
  71. </td>
  72. </tr>
  73. <tr>
  74. <td>Social Security Number : <br>
  75. <small><input onKeyUp="return autoTab(this, 3, event);" size="4" maxlength="3"></small> - 
  76. <small><input onKeyUp="return autoTab(this, 2, event);" size="3" maxlength="2"></small> - 
  77. <small><input onKeyUp="return autoTab(this, 4, event);" size="5" maxlength="4"></small>
  78. </td>
  79. </tr>
  80. </table>
  81. </form>
  82. </center>
  83.  
  84. <!-- END OF SCRIPT -->
  85. <!/SCRIPT>
  86.  
  87. <!PREVIEW>
  88. <!-- START OF SCRIPT -->
  89.  
  90. <!-- HOW TO INSTALL AUTO TAB:
  91.  
  92.   1.  Copy code into the HEAD section of document
  93.   2.  Put last coding into the BODY section of document  -->
  94.  
  95. <!-- STEP ONE: Add code into HEAD section of document  -->
  96.  
  97. <HEAD>
  98.  
  99. <SCRIPT LANGUAGE="JavaScript">
  100. <!-- Original:  Cyanide_7 (leo7278@hotmail.com) -->
  101. <!-- Web Site:  http://members.xoom.com/cyanide_7 -->
  102.  
  103.  
  104. <!-- Begin
  105. var isNN = (navigator.appName.indexOf("Netscape")!=-1);
  106. function autoTab(input,len, e) {
  107. var keyCode = (isNN) ? e.which : e.keyCode; 
  108. var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46];
  109. if(input.value.length >= len && !containsElement(filter,keyCode)) {
  110. input.value = input.value.slice(0, len);
  111. input.form[(getIndex(input)+1) % input.form.length].focus();
  112. }
  113. function containsElement(arr, ele) {
  114. var found = false, index = 0;
  115. while(!found && index < arr.length)
  116. if(arr[index] == ele)
  117. found = true;
  118. else
  119. index++;
  120. return found;
  121. }
  122. function getIndex(input) {
  123. var index = -1, i = 0, found = false;
  124. while (i < input.form.length && index == -1)
  125. if (input.form[i] == input)index = i;
  126. else i++;
  127. return index;
  128. }
  129. return true;
  130. }
  131. //  End -->
  132. </script>
  133. </HEAD>
  134.  
  135. <!-- STEP TWO: Add code into BODY section of document  -->
  136.  
  137. <BODY>
  138.  
  139. <center>
  140. <form>
  141. <table>
  142. <tr>
  143. <td>Phone Number : <br>
  144. 1 - (
  145. <small><input onKeyUp="return autoTab(this, 3, event);" size="4" maxlength="3"></small>) - 
  146. <small><input onKeyUp="return autoTab(this, 3, event);" size="4" maxlength="3"></small> - 
  147. <small><input onKeyUp="return autoTab(this, 4, event);" size="5" maxlength="4"></small>
  148. </td>
  149. </tr>
  150. <tr>
  151. <td>Social Security Number : <br>
  152. <small><input onKeyUp="return autoTab(this, 3, event);" size="4" maxlength="3"></small> - 
  153. <small><input onKeyUp="return autoTab(this, 2, event);" size="3" maxlength="2"></small> - 
  154. <small><input onKeyUp="return autoTab(this, 4, event);" size="5" maxlength="4"></small>
  155. </td>
  156. </tr>
  157. </table>
  158. </form>
  159. </center>
  160.  
  161. <!-- END OF SCRIPT -->
  162. <!/PREVIEW>
  163.  
  164. <!RELATED>NONE<!/RELATED>
  165.